'''
账号类Account, 记录某人 存的钱数, 可以实现转账,收款,并记录转账和收款的明细以及日期
today = str(datetime.date.today())
2021-8-14 Nasa
'''
import datetime


class Account:
    def __init__(self, name, qian):
        self.qian = qian
        self.name = name
        self.jilu = []

    def qian_out(self, n, account):
        if 0 < n < self.qian:
            self.qian -= n
            # print('钱已发出')
            account.qian += n
            # print(f'{account.name}已收钱')
            jintian = str(datetime.date.today())
            self.jilu.append(f'{jintian},{self.name}转钱给{account.name},{n}')
            account.jilu.append(f'{jintian},{self.name}转钱给{account.name},{n}')
            return True
        else:
            # print('转钱失败')
            return False

    # def qian_in(self, n):
    #     if n > 0:
    #         self.qian += n
    #         print('钱已收入')
    #     else:
    #         print('钱不能为负')


if __name__ == '__main__':
    def main():
        me = input('请输入你的姓名:')
        me_qian = int(input('请输入你的钱:'))
        you = input('请输入第二个人的姓名:')
        you_qian = int(input('请输入第二个人的钱:'))
        me = Account(me, me_qian)
        you = Account(you, you_qian)
        # 你给对方转账, 请选择转账金额

        while True:
            trfa = input('是(y)否(n)转钱?')
            if trfa == '否' or trfa == 'n':
                break
            jine = int(input('转多少钱?'))
            if me.qian_out(jine, you):
                print('转钱成功!')
            else:
                print('转钱失败!')

        print(me.jilu)


    main()
